//
//  YMHomeTipInforAlert.m
//  YMMedical
//
//  Created by y s on 2023/7/21.
//

#import "YMHomeTipInforAlert.h"

@interface YMHomeTipInforAlert ()

@property (nonatomic, strong) UIImageView *imgvIcon;
@property (nonatomic, strong) UILabel *lblTitle;
@property (nonatomic, strong) UILabel *lblContent;

@property (nonatomic, strong) UIButton *btnCancle;
@property (nonatomic, strong) UIButton *btnSure;


@end

@implementation YMHomeTipInforAlert

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark -- UI
- (void)setUI{
    [self.vAlert addSubview:self.imgvIcon];
    [self.vAlert addSubview:self.lblTitle];
    [self.vAlert addSubview:self.lblContent];
    [self.vAlert addSubview:self.btnSure];
    [self.vAlert addSubview:self.btnCancle];
    
    [self.imgvIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo([SFitUtil fit:20]);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo([SFitUtil fitSize:140 height:140]);
    }];
    [self.lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imgvIcon.mas_bottom).offset([SFitUtil fit:20]);
        make.centerX.mas_equalTo(0);
        make.left.mas_greaterThanOrEqualTo([SFitUtil fit:15]);
    }];
    [self.lblContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lblTitle.mas_bottom).offset([SFitUtil fit:20]);
        make.left.mas_equalTo([SFitUtil fit:30]);
        make.right.mas_equalTo([SFitUtil fit:-30]);
    }];
    [self.btnCancle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo([SFitUtil fit:-20]);
        make.left.mas_equalTo([SFitUtil fit:30]);
        make.size.mas_equalTo([SFitUtil fitSize:120 height:44]);
        make.top.equalTo(self.lblContent.mas_bottom).offset([SFitUtil fit:20]);
    }];
    [self.btnSure mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.btnCancle);
        make.right.mas_equalTo([SFitUtil fit:-30]);
        make.size.equalTo(self.btnCancle);
    }];
}

- (void)sureClickAction:(id)sender{
    if (self.sureBlock){
        self.sureBlock();
    }
    [self dismiss];
}

- (void)setStrTitle:(NSString *)strTitle{
    _strTitle = strTitle;
    self.lblTitle.text = strTitle;
}
- (void)setIconName:(NSString *)iconName{
    if (iconName != nil && iconName.length > 0){
        self.imgvIcon.image = [UIImage imageNamed:iconName];
    }
}
- (void)setStrContent:(NSString *)strContent{
    _strContent = strContent;
    self.lblContent.text = strContent;
}

#pragma mark -- setter and getter
- (UIImageView *)imgvIcon{
    if (_imgvIcon == nil){
        _imgvIcon = [[UIImageView alloc] init];
        _imgvIcon.image = [UIImage imageNamed:@"alert_tips_infor_icon"];
    }
    return _imgvIcon;
}
- (UILabel *)lblTitle{
    if (_lblTitle == nil){
        _lblTitle = [SThemeUtil boldLabel:KLanguage(@"hint_txt") color:STheme.H_D1 fontSize:18];
    }
    return _lblTitle;
}
- (UILabel *)lblContent{
    if (_lblContent == nil){
        _lblContent = [SThemeUtil label:@"" color:STheme.H_D3 fontSize:14];
        _lblContent.textAlignment = NSTextAlignmentCenter;
        _lblContent.numberOfLines = 0;
    }
    return _lblContent;
}
- (UIButton *)btnSure{
    if (_btnSure == nil) {
        _btnSure = [UIButton buttonWithType:UIButtonTypeCustom];
        _btnSure.titleLabel.font = [SFitUtil fitBoldFont:16];
        [_btnSure setTitleColor:STheme.D9 forState:UIControlStateNormal];
        [_btnSure setTitle:KLanguage(@"sure_txt_key") forState:UIControlStateNormal];
        [_btnSure addTarget:self action:@selector(sureClickAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnSure.clipsToBounds = YES;
        _btnSure.layer.cornerRadius = [SFitUtil fit:10];
        _btnSure.backgroundColor = STheme.D12;
    }
    return _btnSure;
}
- (UIButton *)btnCancle{
    if (_btnCancle == nil) {
        _btnCancle = [UIButton buttonWithType:UIButtonTypeCustom];
        _btnCancle.titleLabel.font = [SFitUtil fitBoldFont:16];
        [_btnCancle setTitleColor:STheme.D1 forState:UIControlStateNormal];
        [_btnCancle setTitle:KLanguage(@"cancle_txt") forState:UIControlStateNormal];
        [_btnCancle addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
        _btnCancle.clipsToBounds = YES;
        _btnCancle.layer.cornerRadius = [SFitUtil fit:10];
        _btnCancle.backgroundColor = STheme.D9;
        _btnCancle.layer.borderWidth = [SFitUtil fitLine];
        _btnCancle.layer.borderColor = [SUIUtil colorOf:0xCCCCCC].CGColor;
    }
    return _btnCancle;
}



@end
